#!/bin/sh
main()
{
. $DOCUMENT_ROOT/apps/home/header.tpl.sh
header_html

cat <<EOF
		<div class="pure-g">
			<div class="l-box-lrg pure-u-1 pure-u-md-1-2">
				<h3>消息盒</h3>
					<table class="pure-table">
						<thead>
							<tr>
								<th>#</th>
								<th>描述</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
EOF
. $DOCUMENT_ROOT/apps/notice/notice_lib.sh
. /usr/share/libubox/jshn.sh
json_load "`cat /tmp/notice_index.json`"
json_get_keys notice_keys
notice_keys=`echo "$notice_keys" | grep -Eo "[0-9]*" | tail -n 10 | sort -nr`
for notice_key in $notice_keys
do
eval i18n_${notice_key}_desc="$(eval echo '$'JSON_TABLE${notice_key}_desc)"
[ -n "$(eval echo '$'i18n_${notice_key}_desc)" ] || eval i18n_${notice_key}_desc="$(eval echo '$'J_T${notice_key}_desc)"
done

json_load "`cat /tmp/notice_data.json`"
for notice_key in $notice_keys
do
json_select
json_select ${notice_key} >/dev/null 2>&1
json_select "variable" >/dev/null 2>&1
json_get_keys var_keys
for var_key in $var_keys
do
json_get_var "${var_key}" "${var_key}"
done
# desc_i18n=`eval echo $(eval echo '$'$(eval echo '$'i18n_${notice_key}_desc) | sed 's/{/${/g')`
desc_i18n=`eval echo '$'$(eval echo '$'i18n_${notice_key}_desc) | sed 's/{/${/g')`
cat <<EOF
<tr><td>${notice_key}</td><td>`eval echo "$desc_i18n" 2>&1`</td><td><button class="pure-button">查看</button><button class="pure-button">删除</button></td></tr>
EOF
done
cat <<EOF
						</tbody>
					</table>

			</div>

			<div class="l-box-lrg pure-u-1 pure-u-md-1-2">

						<h4>Contact Us</h4>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
							tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
							quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
							consequat.
						</p>

						<h4>More Information</h4>
						<p>
							Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
							tempor incididunt ut labore et dolore magna aliqua.
						</p>
						<br/>
						<br/>
						<br/>
						<br/>
						<br/>

			</div>
		</div>
EOF


footer_html
}
save_system_setting()
{
uci set system.@system[0].hostname="$FORM_hostname"
uci set system.@system[0].timezone="$FORM_timezone"
main.sbin go_success
}

lang=`main.sbin get_client_lang`
eval `cat $DOCUMENT_ROOT/apps/$FORM_app/i18n/$lang/i18n.conf`
if
[ $is_main_page = 1 ]
then
main
elif [ -n "$FORM_action" ]
then
$FORM_action
fi
